import createContext from "./createContext";

const dataReducer = (state, action) => {
  switch (action.type) {
    case "add_data":
      return state;
    // case "edit_data":
    //   return state.map((dataCard) => {
    //     return dataCard.id === action.payload.id ? action.payload : dataCard;
    //   });
    // case "delete_data":
    //   //   console.log("deleting");
    //   //   console.log(action.payload);
    //   return state.filter((dataCard) => dataCard.id !== action.payload);
    default:
      return state;
  }
};

const addDataCard = (dispatch) => {
  return () => {
    dispatch({ type: "add_data" });
  };
};

export const { Context, Provider } = createContext(
  dataReducer,
  { addDataCard },
  ["登录"]
);
